package com.ruoyi.ResDishes.service.impl;

import com.ruoyi.ResDishes.domain.ResDishes;
import com.ruoyi.ResDishes.mapper.ResDishesMapper;
import com.ruoyi.ResDishes.service.ResDishesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ResDishesServiceImpl implements ResDishesService {

    @Autowired
    ResDishesMapper resDishesMapper;
    @Override
    public ResDishes selectResDishesById(Long id) {
        return resDishesMapper.getDishesById(id);
    }

    @Override
    public List<ResDishes> selectResDishesByParamIf(ResDishes resDishes) {
        return resDishesMapper.selectDishesByIf(resDishes);
    }

    @Override
    public List<ResDishes> selectResDishesByParamWhen(ResDishes resDishes) {
        return resDishesMapper.selectDishesByWhen(resDishes);
    }

    @Override
    public int insertResDishes(ResDishes resDishes) {
        resDishes.setCreate_by("董虹妤");
        resDishes.setCreate_time(new Date());
        return resDishesMapper.insertNewresDishes(resDishes);
    }

    @Override
    public int updateResDishes(ResDishes resDishes) {
        resDishes.setUpdate_by("董虹妤");
        resDishes.setUpdate_time(new Date());
        return resDishesMapper.updateNewresDishes(resDishes);
    }

    @Override
    public int deleteResDishesById(Long id) {
        return resDishesMapper.deleteNewresDishes(Math.toIntExact(id));
    }
}
